/*
 * @FileName: bsp_comp.h
 * @Author: GreyQiu qiushaogui@aikosolar.com
 * @Date: 2023-07-13 10:46:40
 * @LastEditors: GreyQiu qiushaogui@aikosolar.com
 * @LastEditTime: 2023-09-07 11:34:53
 * @Description: 
 * 
 * Copyright (c) 2023, All Rights Reserved. 
 */

#ifndef __BSP_COMP_H__
#define __BSP_COMP_H__
#include "n32g430.h"

#define DAC_RADIO (63.0f / 3.3f) // 1V对应DAC值

// 短路保护电流设置
#define SCP_HB1_TH      15.0f   // 15A保护
#define RSENSE          0.002f  // 采样电阻值2m欧姆
#define AMP_OFFSET      1.65f   // 电流放大器偏置
#define AMP_GAIN        50.0f   // 电流放大器增益
#define VIIN            (SCP_HB1_TH * RSENSE * AMP_GAIN + AMP_OFFSET) // SCP阈值时端口电压值

#define CMP_VAL_HB1     61 //(uint32_t)((SCP_HB1_TH * RSENSE * AMP_GAIN + AMP_OFFSET) / 3.3f * 63)// 电感峰值电流保护25A


void bsp_comp_init(void);
void bsp_comp_enable(void);
void bsp_comp_disable(void);
#endif
